<?php
$arr1 = array( 'id' => 3, 'name' => 'lisi', 'sex' => 'f');
$arr2 = array('id' => 4, 'address' => array('beijing', 'huibei', 'shanghai'));
$data = array_merge($arr1, $arr2);
//var_dump($data);

$arr1 = array(1,2,3);
$arr2 = array(3,4,5);
$data = $arr1 + $arr2;  //如果你想完全保留原有数组并只想新的数组附加到后面
$data2 = array_merge($arr1, $arr2);
//var_dump($data,$data2);

/**
 * 递归合并的问题
 */
$arr1 = ['enable' => true];
$arr2 = ['enable' => true];
$data3 = array_merge_recursive($arr1, $arr2);
var_dump($data3);

$arr1 = [
    'enable' => true,
    'option' => ['type' => 'json', 'timeout' => 4],
    'infos' => [
        'a' => ['uid'=> '100574', 'age' => 15]
    ],
    'uids' => ['a', 'b']

];
$arr2 = [
    'enable' => false,
    'option' => ['type' => 'text', 'timeout' => 1],
    'infos' => [
        'a' => ['uid'=> '28808', 'age' => 88]
    ],
    'uids' => ['c', 'd'],
];
$data3 = array_merge_recursive($arr1, $arr2);
var_dump($data3);

/**
 * array_merge_recursive() 不可合并数字键
 */
//二维数组
$arr1 = array(
    0 => array('10048' => 'lisi', '10049' => 'zhangsan'),
    1 => array('20048' => 'waner', '10049' => 'mazi'),
);
$arr2 = array(
    1 => array('30048' => 'herry', '30049' => 'amzing'),
);
$data = $arr1 + $arr2;
$data2 = array_merge($arr1, $arr2);
$data3 = array_merge_recursive($arr1, $arr2);
var_dump($data, $data2, $data3);






// $push_cate_list = array(8 => "模特", 10 => "健身", 11 => "按摩", 12 => "练唱歌", 13 => "导游", 15 => "瑜伽", 16 => "舞蹈", 17 => "羽毛球", 19 => "游泳", 21 => "美发", 22 => "美甲", 23 => "美妆", 25 => "摄影", 41 => "心理咨询", 43 => "兼职厨师", 54 => "宠物", 57 => "情感咨询", 58 => "享美食", 59 => "带跑步", 60 => "看电影", 61 => "逛商场", 62 => "玩游戏", 65 => "占卜", 67 => "台球", 68 => "高尔夫", 73 => "美容");
// $push_cate_sex = array(8 => 1, 10 => 3, 11 => 1, 12 => 3, 13 =>1, 15 => 2, 16 => 2, 17 => 1, 19 => 1, 21 => 2, 22 => 2, 23 => 2, 25 => 3, 41 => 3, 43 => 3, 54 => 2, 57 => 3, 58 => 3, 59 => 3, 60 => 3, 61 => 2, 62 => 1, 65 => 2, 67 => 1, 68 => 1, 73 => 2);
// $push_cate[1] = array_merge(array_keys($push_cate_sex, 1), array_keys($push_cate_sex, 3));
// $push_cate[2] = array_merge(array_keys($push_cate_sex, 2), array_keys($push_cate_sex, 3));
// $push_sex[1] = array_fill_keys($push_cate[1], 1);   //设置所有的值为1
// $push_sex[2] = array_fill_keys($push_cate[2], 2);   //设置所有的值为1
// var_dump($push_cate, $push_sex);

//1.如果数组包含数字键名，后面的值将 不会 覆盖原来的值，而是附加到后面。
$array1 = array(2 => "data", 'hai' => 'fuck', 4 => 'dump');
$array2 = array(1 => "data");
$result = array_merge($array1, $array2);
var_export($result);


$first = array(
    array(
        'type' => 'tip',
        'def' => '',
    ),
);

$second = array(
    array(
        'name' => 'money',
        'type' => 'test',
        'def' => '',
    ),
);        
$three = array(
    /************************隐藏属性************************/
    array(
        'name' => 'token',
        'type' => 'test',
        'def' => '',
    ),
);

$element = array_merge($first, $second, $three);
var_dump($element);